package com.lzl.service;

import com.lzl.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory {

    @Override
    public DeptClientService create(Throwable throwable) {
        // 这里做的操作就是配置当出现异常的时候, 调用我们这里工厂中配置的失败时调用的方法
        return new DeptClientService() {
            @Override
            public Dept selectById(Long id) {
                return new Dept().setDeptno(id).setDbSource("没有拉~~~~~").setDname("现在是客户端提供的降级信息");
            }

            @Override
            public List<Dept> selectAll() {
                return null;
            }
        };
    }
}
